<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of XinqinglistLogic
 *
 * @author Administrator
 */
class XinqinglistLogic extends BaseLogic{
    //put your code here
    private $xinqinglistTable;
    public function __construct() {
        parent::__construct();
        $this->xinqinglistTable=  $this->load("xinqinglist");
        $this->table=  $this->xinqinglistTable;
    }
    /**
     *    保存和更新心情列表
     * @param type $data 心情信息
     * @param type $id   心情id
     * @return type  
     */
    public function save($data,$id=0){
        if($id>0){
            $res=  $this->xinqinglistTable->update($data,"id={$id}");
        }else{
            $res=$this->xinqinglistTable->insert($data,TRUE);
        }
        return $res;
    }
    /**
     * 获得心情列表
     * @param type $where 条件
     * @param type $pageid  页码
     * @param type $pagecount   页数
     * @param type $orderby   排序
     * @return type   列表
     */
    public function getList($where="1=1",$pageid=1,$pagecount=100,$orderby="order by listorder asc"){
       $data=array();
       $res=$this->xinqinglistTable->select_page("*", $where, $pageid, $pagecount,$orderby);
       $count=  $this->xinqinglistTable->get_count($where);
       $data["list"]=$res;
       $data["pagedata"]=$count;
       return $data;
    }
    /**
     * 获得心情信息
     * @param type $xinqing_id 心情id
     * @return boolean 心情信息
     */
     public function getXinQingInfo($xinqing_id){
        if($xinqing_id){
           $xinqing=  $this->xinqinglistTable->get_one("*", "id={$xinqing_id} and status=1");
           return $xinqing;
       }
       return FALSE;
    }
}
